/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * pool.java
 *
 * Created on 19-feb-2011, 16:42:31
 */

package jfreefall;

import java.awt.Cursor;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import logica.objCaida;
import org.jfree.ui.RefineryUtilities;

/**
 *
 * @author joshi
 */
public class pool extends javax.swing.JFrame implements Runnable {

    /** Creates new form pool */
    public static double h = 100;
    public static double velocidad =0;
    public static double tiempo = 0;
    public static double gravedad = 9.8;
    public static boolean topen = false, aopen=false, gopen = false;
    public static double det=0;
    public static double x0=0, y0=0, xn=0, yn=0;
    public static double b0=0, b1=0;
    public static boolean pausa=false;

    public static excel ex;

    objCaida obj;

    public pool() {
        initComponents();
        setIconImage(new ImageIcon(getClass().getResource("/img/labs.png")).getImage());
        this.setLocationRelativeTo(null);
        this.setExtendedState(MAXIMIZED_BOTH);
        this.jSeparator2.setBounds(0, objCaida.CONST+23, 1800, 50);

        //creamos la lista
        ex = new excel();
            
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        jToolBar1 = new javax.swing.JToolBar();
        jButton1 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jSplitPane1 = new javax.swing.JSplitPane();
        jPanel3 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        tvelocidad = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        ttiempo = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jgravedad = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        taltura = new javax.swing.JTextField();
        jpos = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jPanel1 = new javax.swing.JPanel();
        jSeparator2 = new javax.swing.JSeparator();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JSeparator();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 100, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 100, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jToolBar1.setRollover(true);

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/Gnome-Document-New-32.png"))); // NOI18N
        jButton1.setFocusable(false);
        jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton1);

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/JTable.gif"))); // NOI18N
        jButton3.setFocusable(false);
        jButton3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton3.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton3);

        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/graph_set.png"))); // NOI18N
        jButton4.setFocusable(false);
        jButton4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton4.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton4);

        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/Gnome-Media-Playback-Pause-32.png"))); // NOI18N
        jButton5.setFocusable(false);
        jButton5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton5.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton5);

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/Gnome-Media-Playback-Start-32.png"))); // NOI18N
        jButton2.setFocusable(false);
        jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton2);

        jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/Gnome-Media-Playback-Stop-32.png"))); // NOI18N
        jButton6.setFocusable(false);
        jButton6.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton6.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton6);

        jSplitPane1.setDividerLocation(50);
        jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        jLabel1.setText("Velocidad Inicial:");

        tvelocidad.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tvelocidadKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tvelocidadKeyReleased(evt);
            }
        });

        jLabel2.setText("Tiempo:");

        ttiempo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                ttiempoKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                ttiempoKeyReleased(evt);
            }
        });

        jLabel3.setText("Gravedad:");

        jgravedad.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Tierra", "Luna", "Marte" }));
        jgravedad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jgravedadActionPerformed(evt);
            }
        });

        jLabel4.setText("Seg.");

        jLabel5.setText("m/s");

        jLabel6.setText("y0:");

        taltura.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                talturaKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                talturaKeyReleased(evt);
            }
        });

        jpos.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jpos.setText("(x,y)");

        org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel6)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(taltura, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 57, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(jLabel1)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(tvelocidad, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 57, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jLabel5)
                .add(27, 27, 27)
                .add(jLabel2)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(ttiempo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 59, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(4, 4, 4)
                .add(jLabel4)
                .add(33, 33, 33)
                .add(jLabel3)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jgravedad, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(jpos, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 142, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap(18, Short.MAX_VALUE)
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel6)
                    .add(taltura, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel1)
                    .add(tvelocidad, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel3)
                    .add(jgravedad, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel2)
                    .add(ttiempo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel4)
                    .add(jLabel5)
                    .add(jpos))
                .addContainerGap())
        );

        jSplitPane1.setLeftComponent(jPanel3);

        jScrollPane1.setAutoscrolls(true);

        jPanel1.setAutoscrolls(true);
        jPanel1.setLayout(null);
        jPanel1.add(jSeparator2);
        jSeparator2.setBounds(30, 350, 670, 2);

        jScrollPane1.setViewportView(jPanel1);

        jSplitPane1.setRightComponent(jScrollPane1);

        jMenu1.setText("Archivo");

        jMenuItem2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/new32.png"))); // NOI18N
        jMenuItem2.setText("Nuevo");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);
        jMenu1.add(jSeparator1);

        jMenuItem3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/application-exit (1).png"))); // NOI18N
        jMenuItem3.setText("Salir");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem3);

        jMenuBar1.add(jMenu1);

        jMenu3.setText("Ver");

        jMenuItem4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/graph_set.png"))); // NOI18N
        jMenuItem4.setText("Grafico");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem4);

        jMenuItem5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/JTable.gif"))); // NOI18N
        jMenuItem5.setText("Valores");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem5);

        jMenuBar1.add(jMenu3);

        jMenu2.setText("Ayuda");

        jMenuItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/help-faq.png"))); // NOI18N
        jMenuItem1.setText("Acerca de");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem1);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jToolBar1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 745, Short.MAX_VALUE)
            .add(jSplitPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 745, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(jToolBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jSplitPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 463, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
      if(!pausa){
        set_valores();
        obj.inicializar();
        }else{
          pausa=false;
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jgravedadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jgravedadActionPerformed
        // TODO add your handling code here:
        set_gravedad();
    }//GEN-LAST:event_jgravedadActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:

        this.set_cursorw();
        nueva_tabla();
        this.set_cursor();
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
        about();
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
        // TODO add your handling code here:
        this.set_cursorw();
        ver_grafico();
        this.set_cursor();
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
        // TODO add your handling code here:
         this.set_cursorw();
        nueva_tabla();
        this.set_cursor();
    }//GEN-LAST:event_jMenuItem5ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        // TODO add your handling code here:
        nuevo();
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        // TODO add your handling code here:
        System.exit(0);
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        nuevo();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
        this.set_cursorw();
        ver_grafico();
        this.set_cursor();
    }//GEN-LAST:event_jButton4ActionPerformed

    private void tvelocidadKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tvelocidadKeyPressed
        // TODO add your handling code here:
        esnumv();
    }//GEN-LAST:event_tvelocidadKeyPressed

    private void tvelocidadKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tvelocidadKeyReleased
        // TODO add your handling code here:
       esnumv();
    }//GEN-LAST:event_tvelocidadKeyReleased

    private void ttiempoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_ttiempoKeyPressed
        // TODO add your handling code here:
        esnum();
    }//GEN-LAST:event_ttiempoKeyPressed

    private void ttiempoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_ttiempoKeyReleased
        // TODO add your handling code here:
        esnum();
    }//GEN-LAST:event_ttiempoKeyReleased

    private void talturaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_talturaKeyPressed
        // TODO add your handling code here:
        esnumy();
    }//GEN-LAST:event_talturaKeyPressed

    private void talturaKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_talturaKeyReleased
        // TODO add your handling code here:
        esnumy();
    }//GEN-LAST:event_talturaKeyReleased

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        // TODO add your handling code here:
        tiempo=0;
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        // TODO add your handling code here:
        pausa=true;
    }//GEN-LAST:event_jButton5ActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new pool().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    public static javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JToolBar jToolBar1;
    public static javax.swing.JComboBox jgravedad;
    public static javax.swing.JLabel jpos;
    public static javax.swing.JTextField taltura;
    public static javax.swing.JTextField ttiempo;
    public static javax.swing.JTextField tvelocidad;
    // End of variables declaration//GEN-END:variables

    public static void set_gravedad() {
        if (jgravedad.getSelectedIndex()==0){
            gravedad = 9.8;
        }
        else if (jgravedad.getSelectedIndex()==1){
            gravedad = 1.62;
        }
        else{
            gravedad = 3.71;
        }

        
    }

    public void set_valores() {
        if (tvelocidad.getText().compareTo("")!=0 && ttiempo.getText().compareTo("")!=0 && taltura.getText().compareTo("")!=0){
            velocidad = java.lang.Double.valueOf(tvelocidad.getText());
            tiempo = java.lang.Double.valueOf(ttiempo.getText());
            h = java.lang.Double.valueOf(taltura.getText());
            if(obj!=null){
                obj.setBounds(10000,10000,50,50);
            }
            obj=new objCaida((float)velocidad,(float)h,gravedad,tiempo);
            jPanel1.add(obj);
            Thread t=new Thread(this);
            t.start();
        }
        else{
            JOptionPane.showMessageDialog(null, "Debe de ingresar valor de velocidad inicial y tiempo","Error de Ingreso",  JOptionPane.INFORMATION_MESSAGE  );
        }
    }

    private void nueva_tabla() {
        if (topen== false){
        tabla tab = new tabla();
        topen = true;
        tab.setVisible(true);
        }
    }

    private void about() {
        if (aopen== false){
        about ab = new about();
        aopen = true;
        ab.setVisible(true);
        }
    }

    private void ver_grafico() {
        grafico gr = new grafico("Gráfico de Regresión");
        gr.pack();
        RefineryUtilities.centerFrameOnScreen(gr);
        gr.setVisible(true);
    }

    private void nuevo() {
        if(obj!=null){
                obj.setBounds(10000,10000,50,50);
                this.taltura.setText("");
                this.ttiempo.setText("");
                this.tvelocidad.setText("");
            }
    }

    private void esnumv() {
        double p = 0.0;
        String valor = tvelocidad.getText();
        try{
            p = java.lang.Double.valueOf(valor);
        }
        catch(Exception e){
            if (valor.length()>1){
            valor = valor.substring(0, valor.length()-1);
            tvelocidad.setText(valor);
            }
            else{
            tvelocidad.setText("");
            }

        }
    }

    private void esnum() {
        double p = 0.0;
        String valor = ttiempo.getText();
        try{
            p = java.lang.Double.valueOf(valor);
        }
        catch(Exception e){
            if (valor.length()>1){
            valor = valor.substring(0, valor.length()-1);
            ttiempo.setText(valor);
            }
            else{
            ttiempo.setText("");
            }

        }
    }

    private void esnumy() {
             double p = 0.0;
        String valor = taltura.getText();
        try{
            p = java.lang.Double.valueOf(valor);
        }
        catch(Exception e){
            if (valor.length()>1){
            valor = valor.substring(0, valor.length()-1);
            taltura.setText(valor);
            }
            else{
            taltura.setText("");
            }

        }
    }

    public void run() {
        tiempo = java.lang.Double.valueOf(ttiempo.getText());
        ttiempo.setEditable(false);
        while(tiempo>0){
            try{
                if(!pausa){
                    ttiempo.setText(Double.toString(tiempo));
                    tiempo=tiempo-0.1;
                }
                Thread.sleep(100);
                
            }catch(Exception ev){}
        }
        ttiempo.setEditable(true);
    }

private void set_cursorw(){
        this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    }
    private void set_cursor(){
        this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    }

}
